<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 10] The java.lang Package</TITLE>
<META NAME="author" CONTENT="Mark Grand">
<META NAME="date" CONTENT="Fri Aug  8 15:22:21 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="java">
<META NAME="title" CONTENT="Java Language Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">
<script language='JavaScript'>
<!--
if (location.replace) {
 location.replace ('ch10_js.htm');
}
// -->
</script>

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Language Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch09_04.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 10</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch10_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<H1 CLASS=chapter><A CLASS="TITLE" NAME="JLR2-CH-10">10. The java.lang Package</A></H1>

<DIV CLASS=htmltoc>

<p>
<b>Contents:</b><br>
<a href='ch10_02.htm'>Byte</a><br>
<a href='ch10_03.htm'>Character</a><br>
<a href='ch10_04.htm'>Class</a><br>
<a href='ch10_05.htm'>ClassLoader</a><br>
<a href='ch10_06.htm'>Cloneable</a><br>
<a href='ch10_07.htm'>Compiler</a><br>
<a href='ch10_08.htm'>Double</a><br>
<a href='ch10_09.htm'>Float</a><br>
<a href='ch10_10.htm'>Integer</a><br>
<a href='ch10_11.htm'>Long</a><br>
<a href='ch10_12.htm'>Math</a><br>
<a href='ch10_13.htm'>Number</a><br>
<a href='ch10_14.htm'>Object</a><br>
<a href='ch10_15.htm'>Process</a><br>
<a href='ch10_16.htm'>Runnable</a><br>
<a href='ch10_17.htm'>Runtime</a><br>
<a href='ch10_18.htm'>SecurityManager</a><br>
<a href='ch10_19.htm'>Short</a><br>
<a href='ch10_20.htm'>String</a><br>
<a href='ch10_21.htm'>StringBuffer</a><br>
<a href='ch10_22.htm'>System</a><br>
<a href='ch10_23.htm'>Thread</a><br>
<a href='ch10_24.htm'>ThreadGroup</a><br>
<a href='ch10_25.htm'>Throwable</a><br>
<a href='ch10_26.htm'>Void</a><br>
<p>
<p>
</DIV>

<P CLASS=para>
The package <tt CLASS=literal>java.lang</tt> contains classes and interfaces that
are essential to the Java language. These include:

<P>
<UL CLASS=itemizedlist>
<li CLASS=listitem><tt CLASS=literal>Object</tt>, the ultimate superclass of
all classes in Java

<P>
<li CLASS=listitem><tt CLASS=literal>Thread</tt>, the class that controls
each thread in a multithreaded program

<P>
<li CLASS=listitem><tt CLASS=literal>Throwable</tt>, the superclass of all error and exception
classes in Java

<P>
<li CLASS=listitem>Classes that encapsulate the primitive data types
in Java

<P>
<li CLASS=listitem>Classes for accessing system resources and other
low-level entities

<P>
<li CLASS=listitem><tt CLASS=literal>Math</tt>, a class that provides standard mathematical
methods

<P>
<li CLASS=listitem><tt CLASS=literal>String</tt>, the class that is used to represent strings

<P>
</UL>
<P CLASS=para>
Because the classes in the <tt CLASS=literal>java.lang</tt>
package are so essential, the <tt CLASS=literal>java.lang</tt>
package is implicitly imported by every Java source file. In other
words, you can refer to all of the classes and interfaces in
<tt CLASS=literal>java.lang</tt> using their simple names.

<P CLASS=para>
<A HREF="ch10_01.htm#JLR2-CH-10-FIG-1">Figure 10.1</A> shows the class hierarchy for
the <tt CLASS=literal>java.lang</tt> package.

<DIV CLASS=figure>
<h4 CLASS=figure><A CLASS="TITLE" NAME="JLR2-CH-10-FIG-1">Figure 10.1: The java.lang package</A></h4>


<p>
<img align=middle src="./figs/jlrf1001.gif" alt="[Graphic: Figure 10-1]" width=502 height=523 border=0>

</DIV>

<DIV CLASS=refnamediv>
<H1>Boolean</H1>

<H2>Name</H2>

Boolean

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.1">Synopsis</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Class Name:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.lang.Boolean</tt>

<p>
<DT CLASS=varlistentry>Superclass:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.lang.Object</tt>

<p>
<DT CLASS=varlistentry>Immediate Subclasses:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Interfaces Implemented:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.io.Serializable</tt>

<p>
<DT CLASS=varlistentry>Availability:<br>
<DD>

<P CLASS=para>
JDK 1.0 or later</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.2">Description</A></h2>

<P CLASS=para>
The <tt CLASS=literal>Boolean</tt> class provides an object wrapper
for a <tt CLASS=literal>boolean</tt> value. This is useful when you
need to treat a <tt CLASS=literal>boolean</tt> value as an object. For
example, there are a number of utility methods that take a reference
to an <tt CLASS=literal>Object</tt> as one of their arguments. You cannot
specify a <tt CLASS=literal>boolean</tt> value for one of these arguments,
but you can provide a reference to a <tt CLASS=literal>Boolean</tt> object
that encapsulates the <tt CLASS=literal>boolean</tt> value. Furthermore,
as of JDK 1.1, the <tt CLASS=literal>Boolean</tt> class is necessary to 
support the Reflection API and class literals.

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.3">Class Summary</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public final class java.lang.Boolean {
    // Constants
    public final static Boolean FALSE;
    public final static Boolean TRUE;
    public final static Class TYPE;                    // New in 1.1
    // Constructors
    public Boolean(boolean value);
    public Boolean(String s);
    // Class Methods
    public static boolean getBoolean(String name);
    public static Boolean valueOf(String s);
    // Instance Methods
    public boolean booleanValue();
    public boolean equals(Object obj);
    public int hashCode();
    public String toString();
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.4">Constants</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.1">TRUE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.1">public static final Boolean TRUE</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant <tt CLASS=literal>Boolean</tt> object that has the
value <tt CLASS=literal>true</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.2">FALSE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.2">public static final Boolean FALSE</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant <tt CLASS=literal>Boolean</tt> object that has the
value <tt CLASS=literal>false</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.3">TYPE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.3"><tt CLASS=literal>public static final Class TYPE </tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Class</tt> object that represents the type
<tt CLASS=literal>boolean</tt>.
It is always true that <tt CLASS=literal>Boolean.TYPE</tt> 
<tt CLASS=literal>==</tt> <tt CLASS=literal>boolean.class</tt>.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.5">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.4">Boolean</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.4"><tt CLASS=literal>public Boolean(boolean value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>boolean</tt> value to be made into
a <tt CLASS=literal>Boolean</tt> object.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Boolean</tt> object with the given
value.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.5"><tt CLASS=literal>public Boolean(String s)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into a <tt CLASS=literal>Boolean</tt>
object.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Boolean</tt> object with the value
specified by the given string. If the string equals <tt CLASS=literal>'true'</tt> (ignoring
case), the value of the object is <tt CLASS=literal>true</tt>; otherwise
it is <tt CLASS=literal>false</tt>.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.6">Class Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.5">getBoolean</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.6"><tt CLASS=literal>public static boolean getBoolean(String name)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>name</tt><br>
<DD>

<P CLASS=para>
The name of a system property.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>boolean</tt> value of the system property.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This methods retrieves the <tt CLASS=literal>boolean</tt> value of a named system
property. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.6">valueOf</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.7"><tt CLASS=literal>public static Boolean valueOf(String s)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into a <tt CLASS=literal>Boolean</tt>
object.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A <tt CLASS=literal>Boolean</tt> object with the value specified
by the given string.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>Boolean</tt> object with
the value <tt CLASS=literal>true</tt> if the string equals 
<tt CLASS=literal>"true"</tt> (ignoring
case); otherwise the value of the object is <tt CLASS=literal>false</tt>.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.7">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.7">booleanValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.8"><tt CLASS=literal>public boolean booleanValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>boolean</tt> value contained by the object.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.8">equals</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.9"><tt CLASS=literal>public boolean equals(Object obj)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>obj</tt><br>
<DD>

<P CLASS=para>
The object to be compared with this object.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the objects are equal; <tt CLASS=literal>false</tt>
if they are not.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.equals()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns <tt CLASS=literal>true</tt> if <tt CLASS=literal>obj</tt>
is an instance of <tt CLASS=literal>Boolean</tt>, and it contains the
same value as the object this method is associated with.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.9">hashCode</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.10"><tt CLASS=literal>public int hashCode()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A hashcode based on the <tt CLASS=literal>boolean</tt> value
of the object.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.hashCode()</tt></DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.10">toString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.11"><tt CLASS=literal>public String toString()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>"true"</tt> 
if the value of the object is <tt CLASS=literal>true</tt>;
<tt CLASS=literal>"false"</tt> otherwise.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.toString()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a string representation of the <tt CLASS=literal>Boolean</tt>
object.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.8">Inherited Methods</A></h2>

<DIV CLASS=informaltable>
<P>
<TABLE CLASS=INFORMALTABLE>
<TR CLASS=row>
<TH ALIGN="left">

<P CLASS=para>
Method</TH>
<TH ALIGN="left">

<P CLASS=para>
Inherited From</TH>
<TH ALIGN="left">

<P CLASS=para>
Method</TH>
<TH ALIGN="left">

<P CLASS=para>
Inherited From</TH>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>clone()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>finalize()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>getClass()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>notify()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>notifyAll()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait(long)</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait(long, int)</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
</TABLE>
<P>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.9">See Also</A></h2>

<P CLASS=para>
<A HREF="ch03_01.htm#JLR2-CH-3-SECT-1.2">Boolean Type</A>;
<A HREF="ch02_02.htm#JLR2-CH-2-SECT-2.3.3">Boolean literals</A>;
<A HREF="ch10_04.htm">Class</A>;
<A HREF="ch10_14.htm">Object</A>;
<A HREF="ch10_22.htm">System</A>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch10_26.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch10_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>Void</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>Byte</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
